Imports System.Collections.Generic
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Web
Imports System.Web.Script.Services

Partial Public Class ItemSearch
    Inherits BasePage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Title = "ITracker: Item Search"
        lblPageHeader.Text = "Item Search: "

        If Not IsPostBack Then
            ' populate ddl
            Dim _vendorlist As List(Of Vendor) = Vendor.FetchList(True)
            ddlVendor.DataTextField = "Name"
            ddlVendor.DataValueField = "ID"
            ddlVendor.DataSource = _vendorlist
            ddlVendor.DataBind()
            ddlVendor.Items.Insert(0, New ListItem(" -- all vendors -- ", ""))
        End If
    End Sub

    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    <WebMethod()> _
    Public Shared Function GetDataForGrid(ByVal a As String, ByVal b As String, ByVal c As String, ByVal d As String) As List(Of InventoryItem)
        Dim _id As New Guid()
        If String.IsNullOrEmpty(d) Then
            _id = Nothing
        Else
            _id = New Guid(d)
        End If
        Return InventoryItem.Search(a, b, c, _id)
        
    End Function
End Class